home *** CD-ROM | disk | FTP | other *** search
- /********************************/
- /********** SAT Collision ][ ***********/
- /********************************/
-
- /*A more advanced version of SAT Collision, demonstrating the use of callback routines*/
- /*(hit task) for collision handling. What has happened is that the apples switch between*/
- /*good and bad, and we are not supposed to eat one when it's bad.*/
-
- /*program CollisionII;*/
-
- #include "SAT.h"
- #include "Collision][.h"
-
-
-
- main()
- {
- SpritePtr ignoreSp;
- long l;
- Point p;
- int ignore;
- Rect gameArea; // temp debug
-
- /*Standard Inits.*/
- MaxApplZone ();
- FlushEvents (everyEvent - diskMask, 0 );
- #ifdef THINK_C
- InitGraf (&thePort);
- #else
- InitGraf (&qd.thePort);
- #endif
- InitFonts ();
- InitWindows ();
- InitMenus ();
- TEInit ();
- InitDialogs (nil); /* no restart proc */
- InitCursor ();
-
- MoreMasters ();
- MoreMasters ();
-
-
- SATConfigure(true, kVPositionSort, kBackwardCollision, 32);
- SATInit(128, 129, 512, 322);
-
- // SetRect(&gameArea, 0, 0, 512, 342);
- // SATCustomInit(128, 129, &gameArea, nil, nil, false, true, true, true, true);
- // ShowWindow(gSAT.wind.port);
- // SATRedraw();
-
- InitMrEgghead();
- InitApple();
-
- GetMouse(&p);
- ignoreSp = SATNewSprite(0, p.h, p.v, &SetupMrEgghead);
- ignoreSp = SATNewSprite(0, 0, SATRand(gSAT.offSizeV - 32), &SetupApple);
-
- HideCursor();
-
- /* Get two channels if possible, since we use fairy long sounds. */
- ignore = SATSoundInitChannels(2);
-
- while (!Button()) {
- l = TickCount();
- SATRun(true);
- /*Start a new sprite once in a while.*/
- if (SATRand(40) == 1)
- ignoreSp = SATNewSprite(0, 0, SATRand(gSAT.offSizeV - 32), &SetupApple);
- while (l > TickCount() - 2L) /*Maximize speed to 30 fps*/
- ;
- };
- ShowCursor();
- FlushEvents(mDownMask, 0); //Flush the mouse click, so we won't click randomly in the Finder!
- SATSoundShutup(); /*Always make sure the sound channel is de-allocated!*/
- }